﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProjectA.Controls;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;

namespace ProjectA.Modules.Menu
{
    public class cSubPage_Menu : cSubPage
    {
        public cSubPage_Menu(frmPrincipal frmPrincipal)
        {
            this.frmPrincipal = frmPrincipal;
            this.BackColor = Color.Transparent;
            InitComponent();
        }

        void worker_DoWork(object sender, DoWorkEventArgs e) { }

        void worker_btMenuMostrarModuloCostos_Click(object sender, RunWorkerCompletedEventArgs e)
        {
            if (frmPrincipal.cPage_General.cbCabeceraSeleccionarProyecto.SelectedIndex == -1)
            {
                MessageBox.Show("Por favor seleccione un proyecto", "ProjectA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                
                frmPrincipal.cPage_General.SubPage_Config.Visible = false;
                this.frmPrincipal.cPage_General.SubPage_Costos.btCostosFacturas.Checked = true;
                this.frmPrincipal.cPage_General.SubPage_Costos.WindowOC_OS.btTabInformacionGen.Checked = true;
                frmPrincipal.cPage_General.SubPage_Costos.Visible = true;
                frmPrincipal.cPage_General.SubPage_Costos.WindowPresupuesto.ProjectSelected = frmPrincipal.cPage_General.SubPage_Costos.CentroDeCostosId;
                frmPrincipal.cPage_General.SubPage_Costos.WindowPresupuesto.ConfigPresupuesto.ProyectoActual(frmPrincipal.cPage_General.SubPage_Costos.CentroDeCostosId);
                frmPrincipal.cPage_General.SubPage_Costos.WindowFacturas.CargarInformacionFacturas(frmPrincipal.cPage_General.SubPage_Costos.CentroDeCostosId);
                frmPrincipal.cPage_General.SubPage_Costos.WindowPresupuesto.InfoPresupuestos();
                frmPrincipal.cPage_General.cbCabeceraSeleccionarProyecto.Enabled = false;
                this.Visible = false;
            }
            this.frmPrincipal.frmLoad.Close();
        }

        private void btMenuMostrarModuloCostos_Click(object sender, EventArgs e)
        {
            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += new DoWorkEventHandler(worker_DoWork);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_btMenuMostrarModuloCostos_Click);
            worker.RunWorkerAsync();

            this.frmPrincipal.frmLoad.ShowDialog();
        }

        private void InitComponent()
        {
            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
            // Controles de la página
            // ----------------------------------------------------------------------------------------------------------------------------------------------------------
            this.btMenuMostrarModuloCostos = new cButton(new Point(93, 25), new Size(157, 125), new EventHandler(btMenuMostrarModuloCostos_Click), Properties.Resources.bt_mcostos_1, Properties.Resources.bt_mcostos_2, Properties.Resources.bt_mcostos_3, Properties.Resources.bt_mcostos_4);
            
            this.Controls.Add(btMenuMostrarModuloCostos);
        }

        //Botones
        public cButton btMenuMostrarModuloCostos { get; set; }

        //FormaPrincipal
        private frmPrincipal frmPrincipal { get; set; }
    }
}
